<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                xmlns:f="http://xmlns.jcp.org/jsf/core">
    <!--开始 博客文章列表-->
    <script>$('.blog-nav-item-text').addClass('active');</script>
    <div class="col-sm-8 blog-main">
        <c:set var="count" value="0"/>
        <c:forEach items="#{articleListBean.textPage.item}" var="post">
            <c:set var="count" value="${count+1}"/>
            <div class="blog-post">
                <h2 class="blog-post-title"><h:link outcome="/article?id=${post.id}" value="${post.title}"/></h2>
                <div class="blog-post-meta">
                    作者：<span class="blog-post-publish-author">${post.author.username}</span> |
                    发表于：<span class="blog-post-publish-date">${post.publishDate}</span> |
                    分类：<span class="blog-post-publish-category">${post.category.name}</span>
                </div>
                <div class="blog-post-content">
                    <c:choose>
                        <c:when test="#{post.content.length() lt 200}">
                            <h:outputText escape="false" value="#{post.content}"/>
                        </c:when>
                        <c:otherwise>
                            <h:outputText escape="false"
                                          value="#{post.content.substring(0,200)} ..."/>
                            <h:link outcome="/article?id=${post.id}" value=" [阅读全文]"/>
                        </c:otherwise>
                    </c:choose>
                </div><!-- /.blog-post-content -->
            </div><!-- /.blog-post -->
        </c:forEach>
        <c:if test="${count eq 0}">
            暂无文章
        </c:if>
        <c:if test="#{articleListBean.textPage.pageTotal gt 1}">
            <!--多于一页-->
            <nav>
                <ul class="pager">
                    <c:choose>
                        <c:when test="#{articleListBean.textPage.pageIndex gt 1}">
                            <li>
                                <h:link outcome="articles" value="上一页">
                                    <f:param name="page" value="#{articleListBean.textPage.pageIndex-1}"/>
                                </h:link>
                            </li>
                        </c:when>
                        <c:otherwise>
                            <li><span>上一页</span></li>
                        </c:otherwise>
                    </c:choose>
                    <c:choose>
                        <c:when test="#{articleListBean.textPage.pageIndex lt articleListBean.textPage.pageTotal}">
                            <li>
                                <h:link outcome="articles" value="下一页">
                                    <f:param name="page" value="#{articleListBean.textPage.pageIndex+1}"/>
                                </h:link>
                            </li>
                        </c:when>
                        <c:otherwise>
                            <li><span>下一页</span></li>
                        </c:otherwise>
                    </c:choose>
                </ul>
            </nav>
        </c:if>

    </div><!-- /.blog-main -->
    <!--结束 博客文章列表-->
</ui:composition>